home *** CD-ROM | disk | FTP | other *** search
/ Windows News 2005 November / WNnov2005.iso / Windows / Equipement / hMailServer / hMailServer-4.1-Build-136.exe / {app} / PHPWebAdmin / accounts_edit.php < prev    next >
Encoding:
PHP Script  |  2005-04-06  |  3.1 KB  |  91 lines

  1. <?php
  2. /*
  3. ** $Id: accounts_edit.php,v 1.7 2005/04/05 20:19:10 hmailserver Exp $
  4. **
  5. **    hMailServer - Web interface
  6. **
  7. **    File formatted using TAB size 4
  8. **
  9. **    Get hMailserver at http://www.hmailserver.com
  10. **
  11. **    Author: Steen Rab°l <srabol@mail.tele.dk>
  12. **    Copyright (c) 2004, Steen Rab°l <srabol@mail.tele.dk>
  13. **
  14. **  This program is free software; you can redistribute it and/or modify
  15. **  it under the terms of the GNU General Public License as published by
  16. **  the Free Software Foundation; either version 2 of the License, or
  17. **  (at your option) any later version.
  18. **
  19. **  You may not change or alter any portion of this comment or credits
  20. **  of supporting developers from this source code or any supporting
  21. **  source code which is considered copyrighted (c) material of the
  22. **  original comment or credit authors.
  23. **
  24. **  This program is distributed in the hope that it will be useful,
  25. **  but WITHOUT ANY WARRANTY; without even the implied warranty of
  26. **  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  27. **  GNU General Public License for more details.
  28. **
  29. **  You should have received a copy of the GNU General Public License
  30. **  along with this program; if not, write to the Free Software
  31. **  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
  32. **
  33. */
  34.  
  35. $DomainID    = hmailGetVar("DomainID",0);
  36. $AccountID    = hmailGetVar("AccountID",0);
  37. $function    = hmailGetVar("function","");
  38. $obDomain    = $obBaseApp->Domains->ItemByDBID($DomainID);
  39.  
  40. if (hmailGetAdminLevel() == 0 && $AccountID != hmailGetAccountID())
  41.     hmailHackingAttemp(); // Domain admin but not for this domain.
  42.  
  43. if (hmailGetAdminLevel() == 1 && $DomainID != hmailGetDomainID())
  44.     hmailHackingAttemp(); // Domain admin but not for this domain.
  45.  
  46. $admin_rights = (hmailGetAdminLevel()  === ADMIN_SERVER || 
  47.                 hmailGetAdminLevel()  === ADMIN_DOMAIN);
  48.  
  49. $hmailSmarty->assign("admin_rights",$admin_rights);
  50.  
  51. switch($function)
  52. {
  53.     case "doedit":
  54.         
  55.         $obAccounts = $obDomain->Accounts();
  56.         $obAccount    = $obAccounts->ItemByDBID($AccountID);
  57.         
  58.         // The following properties are only changable
  59.         // by a server admin or a domain admin.        
  60.         if ($admin_rights)
  61.         {
  62.                 $obAccount->MaxSize        = hmailGetVar("MaxSize");
  63.                $obAccount->Active        = (hmailGetVar("Active") == "1") ? 1 : 0;
  64.             $obAccount->Address  = hmailGetVar("Address") . "@" . $obDomain->Name;
  65.           }        
  66.  
  67.           // Password is changeable by the user.
  68.         if (!(hmailGetVar("Password") == ""))
  69.             $obAccount->Password    = hmailGetVar("Password");
  70.  
  71.         $obAccount->Save();
  72.         
  73.         header("refresh: 0; url=index.php?page=accounts_edit&AccountID=$AccountID&DomainID=$DomainID");
  74.         
  75.         exit();
  76.         break;
  77.  
  78.     default:
  79.         $obAccounts = $obDomain->Accounts();
  80.         $obAccount    = $obAccounts->ItemByDBID($AccountID);
  81.         
  82.         $address = substr($obAccount->Address, 0, strpos($obAccount->Address, "@"));
  83.         
  84.         $hmailSmarty->assign("address",$address);
  85.         $hmailSmarty->assign("account",$obAccount);
  86.         $hmailSmarty->assign("domain",$obDomain);
  87.         $hmailSmarty->assign("accountsize", Round($obAccount->Size(), 3));
  88.         $hmailSmarty->assign("pagecontent", $hmailSmarty->fetch('accounts_edit.tpl'));
  89.         break;
  90. }
  91. ?>